import BaseController from './base';
export default class HomeController extends BaseController {
  public async index() {
    const { ctx } = this;
    const param = ctx.request.body;
    try {
      ctx.validate({
        phone: { type: 'telphone' },
        nickname: { type: 'nickname' }
      });
      let req = await super.getData(param);
      if (!req) {
        ctx.body = await this.returnData(false, new Object(), "身份失效，请重新登录");
        return;
      }
      // 自定义config
      console.log(this.config.sourceUrl);
      await this.app.redis.set('key', 'value');
      const value = await this.app.redis.get('key');
      console.log(value);
      let data = await ctx.service.news.sayHi('egg');
      ctx.body = await super.returnData(true, data, "");
    } catch (error: any) {
      ctx.body = await super.returnData(false, new Object(), error.errors[0].message);
    }
  } 
}
